<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "asr_audio".
 *
 * @property int $audio_id 自动播放的录音文件的记录自增id
 * @property int $create_at 创建时间
 * @property string $name 自动播放的录音文件的名字
 * @property int $states 审核是否通过
 * @property int $audio_classify_id 外键关联asr_audio_classify
 *
 * @property AsrAudioClassify $audioClassify
 */
class AsrAudio extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'asr_audio';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['create_at', 'audio_classify_id'], 'integer'],
            [['create_at'], 'default','value'=>time()],
            [['name'], 'required'],
            [['name'], 'string', 'max' => 30],
            [['states'], 'default','value'=>0],
            [['audio_classify_id'], 'exist', 'skipOnError' => true, 'targetClass' => AsrAudioClassify::className(), 'targetAttribute' => ['audio_classify_id' => 'audio_classify_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'create_at' => '创建时间',
            'name' => '流程名称',
            'states' => '流程状态',
            'audio_classify_id' => '所属种类',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getAudioClassify()
    {
        return $this->hasOne(AsrAudioClassify::className(), ['audio_classify_id' => 'audio_classify_id']);
    }
}
